//
//(1) Employee：这是所有员工总的父类。
//
//① 属性：员工的姓名,员工的生日月份
//
//② 方法：getSalary(int month) 根据参数月份来确定工资，如果该月员工过生日，则公司会额外奖励 100 元。
//
//(2) SalariedEmployee：Employee 的子类，拿固定工资的员工。
//
//① 属性：月薪。
//
//(3)HourlyEmployee：Employee 的子类，按小时拿工资的员工，每月工作超出160 小时的部分按照1.5倍工资发放。
//
//① 属性：每小时的工资、每月工作的小时数。
//
//(4) SalesEmployee：Employee 的子类，销售，工资由月销售额和提成率决定。
//
//① 属性：月销售额、提成率。
//
//(5) BasePlusSalesEmployee：SalesEmployee 的子类，有固定底薪的销售人员，工资由底薪加上销售提成部分。
//
//① 属性：底薪。
//
//本题要求根据上述雇员分类，编写一个程序，实现以下功能：
//
//（1）创建一个 Employee 数组，分别创建若干不同的 Employee 对象，并打印某个月的工资。
//
//（2）每个类都完全封装，不允许非私有化属性

//定义父类抽象类
abstract class Employee{
    private String name;
    private int month;

    //get && set
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    //构造函数
    public Employee(){}

    public Employee(String name,int month){
        this.name = name;
        this.month = month;
    }

    public double getSalary(int month){
        int salary = 0;
        //生日多发100
        if(month == this.month)
            salary += 100;

        return salary;
    }
}

//固定工资员工
class SalariedEmployee extends Employee{
    //月薪
    private int monthSalary;

    public SalariedEmployee() {}

    public SalariedEmployee(String name, int month, int monthSalary) {
        super(name, month);
        this.monthSalary = monthSalary;
    }

    public int getMonthSalary() {
        return monthSalary;
    }

    public void setMonthSalary(int monthSalary) {
        this.monthSalary = monthSalary;
    }

    @Override
    public double getSalary(int month) {
        double salary = monthSalary + super.getSalary(month);//后者判断是否过生日加薪
        return salary;
    }
}

//小时工
class HourlyEmployee extends Employee{
    //时薪+小时
    private double hourlySalary;
    private int monthHours;

    public double getHourlySalary() {
        return hourlySalary;
    }

    public void setHourlySalary(double hourlySalary) {
        this.hourlySalary = hourlySalary;
    }

    public int getHours() {
        return monthHours;
    }

    public void setHours(int hours) {
        this.monthHours = hours;
    }

    public HourlyEmployee() {}

    public HourlyEmployee(String name, int month, int monthHours, double hourlySalary) {
        super(name, month);
        this.hourlySalary = hourlySalary;
        this.monthHours = monthHours;
    }

    @Override
    public double getSalary(int month) {
        if(monthHours < 0){
            System.out.println("worng times");
            return 0;
        } else if (monthHours <= 160) {//工时小于160h，正常发薪
            return hourlySalary * monthHours + super.getSalary(month);
        }else {//工时大于160h，超出部分1.5倍薪资
            return hourlySalary * monthHours + (monthHours-160) * 1.5 + super.getSalary(month);
        }
    }
}
//销售
class SalesEmployee extends Employee{
    private double sales;
    private double rate;

    public double getSales() {
        return sales;
    }

    public void setSales(double sales) {
        this.sales = sales;
    }

    public double getRate() {
        return rate;
    }

    public void setRate(double rate) {
        this.rate = rate;
    }

    public SalesEmployee() {
    }

    public SalesEmployee(String name, int month, double sales, double rate) {
        super(name, month);
        this.sales = sales;
        this.rate = rate;
    }

    @Override
    public double getSalary(int month){
        return this.getSales() * (1+this.getRate()) + super.getSalary(month);
    }
}
//固定底薪销售人员
class BasePlusSalesEmployee extends SalesEmployee{
    private int BaseSalary;

    public int getBaseSalary() {
        return BaseSalary;
    }

    public void setBaseSalary(int baseSalary) {
        BaseSalary = baseSalary;
    }

    public BasePlusSalesEmployee() {}

    public BasePlusSalesEmployee(String name, int month, double sales, double rate, int baseSalary) {
        super(name, month, sales, rate);
        BaseSalary = baseSalary;
    }

    @Override
    public double getSalary(int month) {
        return BaseSalary + super.getSalary(month);
    }
}

public class Task2 {
    public static void main(String[] args) {
        Employee[] employees = {
                new SalariedEmployee("李田所",11,4514),
                new HourlyEmployee("刘淳平",4,140,18),
                new SalesEmployee("我修院",5,100,0.5),
                new BasePlusSalesEmployee("张德川",12,50,0.5,3000)
        };

        System.out.println("四月份工资：");

        for(int i = 0; i < employees.length; i++){
            System.out.println("姓名：" + employees[i].getName() + ' '
                    + "生日月份：" + employees[i].getMonth() + ' '
                    + "工资：" + employees[i].getSalary(4));
        }
    }
}
